home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
3565-4.665
/
dmg-4385
/
issue_10
/
23.pne
< prev
next >
Wrap
Text File
|
1987-04-21
|
33KB
|
1,192 lines
****************************************************************
Tony here....Before you start on this months tutorial i
must explain something, As usual William has done you all
proud by bringing you another massive packed tutorial, I tried
writing a tutorial and beleive me it is very hard work,
Well this months tutorial is so big that i have had to split
it into two seperate files, Both are in this issue of course,
And as usual all the relative files ASC's etc are in a folder
on this disk, So it is Basic Tut 10/1 AND basic Tut 10/2, They
are next to each other on the menu so there shouldent be a
problem,
***************************************************************
I assume little/no prior knowledge of Stos. Each lesson will also
have a Stos BASic or ASCii file to go with it.
Listed here for your convenience. i.e. to make it easier to write
them down or to look at the structure of the command. Are the new
commands to be dealt with.
Do not worry if you find things hard at first, practice makes
perfect. Actual progs are used to explain things, called
'name.asc' and included in this folder.
The Main Commands:
SET ZONE: RESET ZONE: READ: RESTORE:
COPY TO: UNSQUASH:
RESERVE SCREEN: SCREEN COPY: GET PALETTE:
If you have any problems, then look for the command on pages 271/73
of the manual. This is not intended to replace the manual,
but to add to it where needed.
Right then, before I start I had better explain where the idea for
this jigsaw programme came from. When I first saw Stos 3D, I saw
that it was possible to create cubes. I then thought of filling
the screen with cubes, so that each cube had part of a picture on
it. This would allow a 6-picture jigsaw, one jigsaw per face on
the cube, but I never got around to mastering Stos 3D.
I think that I said that I intended to finish the jigsaw programme
this time, well sadly that is not to be. As the programmes
themselves take up around 21 pages - each one is printed twice - I
have decided that I would have had to jump too far from subgect to
subject, in order to cram it all in.
So, this month sees the jigsaw up and running, but with no checks
to see if the jigsaw is completed, or completed corectly. Next
month will deal with squashing, and the month after that will deal
with the complete jigsaw programme.
This way, I can give you some pictures to load into the jigsaw
programme. As they will be packed to save space, there was little
point in including them in this tutorial. But I will include some
for the next two tutorials - all being well.
And on to the tutorial. The first two lessons deal with setting
up zones to detect things, and then the there are three versions
of the jigsaw programme - although only the final one is really
complete. the other two just being demos.
LESSON 1
This lesson justs draws boxes and zones to screen, and then ends.
10 rem-----------------------------
20 rem---- ----
30 rem---- SET ZONES ----
40 rem---- ----
50 rem-----------------------------
60 cls : key off
70 if mode<>0 then mode 0
80 reset zone
90 for F=1 to 9
100 read A,B,C,D
110 set zone F,A,B to C,D
120 box A,B to C,D
130 next F
140 data 0,0,32,18,32,0,63,18
150 data 0,19,32,37,32,19,63,37
160 data 0,38,32,66,32,38,63,66
170 data 0,67,32,95,32,67,63,95
180 data 0,96,63,119
And what it does.
Lines:
10 rem-----------------------------
20 rem---- ----
30 rem---- SET ZONES ----
40 rem---- ----
50 rem-----------------------------
Are the title. Sometimes I number the first of a series, somtimes
I only number from the second in the series. So this really
should have been 'SET ZONES 1', but it is not that important.
Lines:
60 cls : key off
70 if mode<>0 then mode 0
Set up the screen. The screen is cleared, and then the menu at
the top of the screen is removed, and then the screen resolution
is checked and altered if needed. In actual fact. The KEY OFF
command is in the wrong place.
The programme clears the screen, then displays the menu, then has
it removed, and then checks the resolution. If the resolution is
changed, then the menu will reappear. This the KEY OFF really
should be on its own line, and after the CLS; and MODE commands.
Line
80 reset zone
Resets the zones. This clears any zones on screen, so that they
will not interfear with the ones being drawn. If zones overlap
then two zones could be activated at the same time. Usually you
want to avoid this, as it makes for trouble.
Line:
90 for F=1 to 9
Sets up a routine to draw 9 boxes and zones. The boxes are there
to show where the zones are. In a proper programme you would more
than likely not want to draw boxes, as it is usually quicker, and
easier, to swap the whole screen.
Line:
100 read A,B,C,D
The READ command looks for the first data statement that it can
find, and reads it, then the next one and so on. In this case it
reads four numbers which will be the locations for the box and
zone to be drawn.
The 'A B C D' is used to manipulate the numbers. READ would work
just as well if it had been 4 'A's or 4'B's. But then it would
have been harder to make use of the values as it would change four
times. This way the values remani the same until they have to be
changed.
Lines:
110 set zone F,A,B to C,D
120 box A,B to C,D
Set up the zones and draw the boxes to the same place. 'F' will
increase each time it is read, so each time it will apply to a
different zone. The 'A B C D' will advance by the number of data
variables read - in this case 4 at a time. In order to read the
first data statement again, you would use a RESTORE command, or
RESTORE line number to jump to specific data.
Line:
130 next F
Closes the looping routine.
Lines:
140 data 0,0,32,18,32,0,63,18
150 data 0,19,32,37,32,19,63,37
160 data 0,38,32,66,32,38,63,66
170 data 0,67,32,95,32,67,63,95
180 data 0,96,63,119
Hold the data. I decided to put two lots of data into the first
four lines and one in the final line. So the programme READs the
first four numbers of line 140, then draws the boxes and zones.
Then the next four lines are read. It does not matter how much
data is on each line. I could have put all the data on one line
if I had wanted.
So why choose the setup that I did. Well if the data is read in
sequance, then the first line refers to the first two boxes drawn.
These boxes happen to be drawn side by side, so I decided to place
them together as data statements.
Basically, the idea is to make it more logical for me/you to read
and understand. Also if you use large lines of data, it is harder
to spot an error, and almost imposible to use RESTORE to
manipulate the data.
I will be covering RESTORE later on, so do not worry about it.
lesson 2
This is lesson 1, but with test routines to show you that the
zones are working.
10 rem-----------------------------
20 rem---- ----
30 rem---- SET ZONES 2 ----
40 rem---- ----
50 rem-----------------------------
60 cls : key off : curs off : clear key
70 if mode<>0 then mode 0
80 reset zone
90 for F=1 to 9
100 read A,B,C,D
110 set zone F,A,B to C,D
120 box A,B to C,D
130 next F
140 rem
150 locate 11,5 : print "Press a key to quit"
160 locate 9,7 : print "Use mouse to test Zones"
170 rem
180 rem
190 rem
200 locate 10,10
210 print zone(0)
220 rem
230 MK=0
240 repeat
250 K$=inkey$
260 if K$<>"" then default : end
270 MK=mouse key
280 until MK<>0
290 rem
300 locate 10,10
330 print zone(0)
350 goto 200
1000 data 0,0,32,18,32,0,63,18
1010 data 0,19,32,37,32,19,63,37
1020 data 0,38,32,66,32,38,63,66
1030 data 0,67,32,95,32,67,63,95
1040 data 0,96,63,119
1230 data 0,67,32,95,32,67,63,95
A bit longer, and not logically numbered in places. I forgot to
renumber it, and now it is too late to mess around.
Lines 340 was deleted and line 1230 is just numbered wrongly. A
renum would have put it right but I forgot.
Lines:
10 rem-----------------------------
20 rem---- ----
30 rem---- SET ZONES 2 ----
40 rem---- ----
50 rem-----------------------------
Are the title of the programme.
Lines:
60 cls : key off : curs off : clear key
70 if mode<>0 then mode 0
80 reset zone
90 for F=1 to 9
100 read A,B,C,D
110 set zone F,A,B to C,D
120 box A,B to C,D
130 next F
Are the same as lesson 1, so I wont add anything more.
Lines:
140 rem
150 locate 11,5 : print "Press a key to quit"
160 locate 9,7 : print "Use mouse to test Zones"
Print messages to screen informing you of how to quit the
programme.
Lines:
170 rem
180 rem
190 rem
200 locate 10,10
210 print zone(0)
Print the current zone to screen. The current zone - in this case
is whichever zone the mouse pointer is over.
Lines:
220 rem
230 MK=0
240 repeat
Resets the value of MK to zero, and then starts a REPEAT loop.
This is so that it can alter the value of MK if needed, or leave
it alone. As this is the first time that MK has been used it
would be defaulting to zero in anycase -I assume that you know
that MK is tha variable that is going to hold the value of the
mouse key - but we need a way of resetting it.
Lines:
250 K$=inkey$
260 if K$<>"" then default : end
Set up another variable. This one tests to see if a key on the
keyboard has been pressed. 'K$' is whichever key - if any - has
been pressed. THen it checks to see if 'K$' is empty {""} ie
nothing between the quotes. If so then it terminates the
programme, if not it continues on to the next line.
Lines:
270 MK=mouse key
280 until MK<>0
Transfer the value of the mousekey pressed into the variable 'MK'.
Remember the mouse keys are valued at 1 = left; 2 = right; and 3 =
both keys. If 'MK' has no value - no mouse key has been pressed,
then the programme loops back to the start of the REPEAT command
UNTIL 'MK' has a value other than zero.
Lines:
290 rem
300 locate 10,10
330 print zone(0)
350 goto 200
Update the printout on screen of which zone the mouse is in. This
only happens if any mouse key is pressed.
Lines:
1000 data 0,0,32,18,32,0,63,18
1010 data 0,19,32,37,32,19,63,37
1020 data 0,38,32,66,32,38,63,66
1030 data 0,67,32,95,32,67,63,95
1040 data 0,96,63,119
1230 data 0,67,32,95,32,67,63,95
Are the same data statements as in lesson 1, so I will not go into
them again.
There was not much to that programme. All I wanted to alow you
was how the zones would work on the larger programmes which are to
follow.
lesson 3
Lines 690 & 700; 740 & 750; 840 & 850 were deleted
This lesson loads a picture; a packed file - one that has been
squashed - than displays them to screen and waits for a key press
before quitting.
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 1 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 190
90 DRV=drive : drive=0 : dir$="A:\"
100 if length(6)=0 then reserve as screen 6
110 if length(7)=0 then reserve as screen 7
120 rem
130 locate 10,10 : print "LOAD PICTURE" : wait 50
140 cls : show on : SCR$=file select$("*.*")
150 F$=SCR$ : BNK=6 : gosub 380
160 rem
170 locate 10,10 : print "LOAD PACed FILE" : wait 50
180 show on : PSCR$=file select$("*.pac")
190 F$=PSCR$ : BNK=8 : gosub 500
200 rem
210 rem
220 rem
230 rem
240 get palette (6)
250 screen copy 6 to back : screen copy 6 to physic
260 reduce 6 to 7,64,0,319,199
270 reduce 6 to 7,0,120,64,199
280 fade 5
290 fade 5,6
300 get palette (6)
310 appear 7
320 rem
330 wait 100 : goto 610
340 rem
350 rem
360 rem ------ FILE LOADER
370 rem
380 hide on : load F$,BNK
390 locate 10,10
400 print F$;" IS LOADED" : wait 50
410 cls : return
420 rem
430 rem ----- PACed FILE LOADER
440 rem
450 locate 10,10 : print "LOAD PACed FILE" : wait 50
460 if length(7)=0 then reserve as screen 7
470 rem
480 rem get size of file to unsquash
490 rem
500 open in #1,F$ : LF=lof(#1) : close #1
510 reserve as work BNK,LF
520 hide on : bload F$,BNK
530 rem
540 rem unsquashing file in a screen bank
550 rem
560 copy start(8),start(8)+LF to start(7)
570 unsquash 7,LF
580 locate 10,10
590 print F$;" IS LOADED" : wait 50
600 cls : return
610 show on
620 reset zone
630 for F=1 to 9
640 read A,B,C,D
650 set zone F,A,B to C,D
660 box A,B to C,D
670 next F
680 rem
710 rem
720 rem
730 rem
760 rem
770 MK=0
780 repeat
790 K$=inkey$
800 if K$<>"" then default : end
810 MK=mouse key
820 until MK<>0
830 rem
860 goto 770
870 data 0,0,32,18,32,0,63,18
880 data 0,19,32,37,32,19,63,37
890 data 0,38,32,66,32,38,63,66
900 data 0,67,32,95,32,67,63,95
910 data 0,96,63,119
920 data 0,67,32,95,32,67,63,95
If you think this is a long programme, than the final lesson is
twice as long. But do not panic. Much of the listing is REM
statements to help you, and the rest has very little in it that is
new to you, so it wont be too hard.
Lines:
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 1 ***
40 rem *** ***
50 rem **************************
Well you know what this is the title. This time I decided to
number the first programme. Sometimes I forget/dont bother.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 if length(1)<>0 then goto 190
90 DRV=drive : drive=0 : dir$="A:\"
Set up the screen and default drives. I am getting tired of
defaulting to the root of drive A:, so I will be introducing a
better system in the last lesson of this tutorial.
Once the Screen has been set up, the programme checks to see if
Memory Bank 1 is empty or not in line 80. If it is empty, the
programme contunues at the next line, if not then it skips the
lines that it does not need and jumps to line 190.
Basically this is a way of ensuring that the programme does not
reset the read lins that it does not need to. After all, if the
programme is just starting, then all the banks will be empty, but
if it is returning after having completed a jigsaw - or in this
case loaded the banks, done what it was meant to and then ended -
we might not want it to load the banks again.
So it is a way of saving time.
Lines:
100 if length(6)=0 then reserve as screen 6
110 if length(7)=0 then reserve as screen 7
Check to see if banks six and seven are in place or not. You can
only reserve the bank once, once it is there yoou can use it as
you wish - provided you load the correct data into it, i.e.
sprites into a sprite bank and pictures into a picture bank.
There is a slight problem with thest screen banks. I decided to
use temporary banks. So they do sometimes disapear after the
programm had ended, and sometimes they remain. It depends on what
you do in the editor screen.
Temporary banks are reserved as SCREENs.
Permenant banks are reserved ad DATA SCREENS.
The difference is that permenant banks are saved with the
programme, and always remain. So you do not need to check them.
However, I am not saving as a BASic file so there is little point
in using permenant screens.
Lines:
120 rem
130 locate 10,10 : print "LOAD PICTURE" : wait 50
Prints a message telling you to load a picture. Actually it would
have been better to place the message at the top of the screen.
Then you would see is whilst the file selector was working.
Lines:
140 cls : show on : SCR$=file select$("*.*")
150 F$=SCR$ : BNK=6 : gosub 380
Clears the screen of the message, and then displays the mouse, and
then the file selector to alow you to load a file. It then loads
this file into Bank six by jumping to a routine at line 380.
Lines:
160 rem
170 locate 10,10 : print "LOAD PACed FILE" : wait 50
180 show on : PSCR$=file select$("*.pac")
190 F$=PSCR$ : BNK=8 : gosub 500
Do the same thing as the previous lines, but this time a PACked
file is going to be nominated in the routine at line 500.
Lines:
200 rem
210 rem
220 rem
230 rem
240 get palette (6)
250 screen copy 6 to back : screen copy 6 to physic
Load the palette from Bank six - this is the colour of the picture
loaded in there - and then copy the contents of Bank six to the
screen. You need to do both the Physical and Background screen so
that the mouse does not erase bits of the screen as it moves.
Remember that the mouse is a sprite, and the screen is updated if
a sprite moves.
Line:
260 reduce 6 to 7,64,0,319,199
Shrinks the picture by the determined amount. The only real limit
to this command is that it only works in multiples of 16. So
'REDUCE 6 to 7,64,0,319,199'
is the same as
'REDUCE 6 to 7, 66,0,319,199'
In the case above, it shrinks from bank 6 to bank 7, and from full
screen to 64,0,319,199. That is from 64 pixels across, 0 pixels
down - a pixel being a single dot on the screen - to 319 across
and 199 down. Which is to the end of the screen.
Line:
270 reduce 6 to 7,0,120,64,199
Does the same as the previous line, but this time copies to the
bottom left hand corner of the sceen stored in Bank 7.
Remember this is being drawn to a screen bank, so you will not see
it untill you display that Bank to screen.
Lines:
280 fade 5
290 fade 5,6
300 get palette (6)
310 appear 7
Fades the screen at a speed of 5, then fades back but this time
displaying the screen stored in Bank 6. Then it get the palette
of Bank 6, and then displays bank 7. Remember bank 7 is where the
pictures have been REDUCEd to, This is why we take bank 6 palette
and not bank 7.
Basically, bank 7 has a palette of its own. anything copied into
bank 7, which already holds part of a picture, will take on the
palette of bank 7. So you need to display the palette from where
the pictures were REDUCED from rather than REDUCED to.
Lines:
320 rem
330 wait 100 : goto 610
Just set up a short delay period so that you can see the screen ,
and then jump to line 610.
Lines:
340 rem
350 rem
360 rem ------ FILE LOADER
370 rem
This is the standard file loader.
Line:
380 hide on : load F$,BNK
Removes the mouse, and loads the file into the Bank number BNK.
Lines:
390 locate 10,10
400 print F$;" IS LOADED" : wait 50
410 cls : return
Inform you that the file was loaded and then clears the screen and
return to wherever it jumped from.
Lines:
420 rem
430 rem ----- PACed FILE LOADER
440 rem
This is the PACked file loader. i.e. it loads squashed files with
the PAC extension.
Lines:
450 locate 10,10 : print "LOAD PACed FILE" : wait 50
460 if length(7)=0 then reserve as screen 7
Prints a message and reserve a screen.
Line:
470 rem
480 rem get size of file to unsquash
490 rem
Are the start of the unsqashing routine.
Line:
500 open in #1,F$ : LF=lof(#1) : close #1
Opens a binary file. Thats how memory banks are stored to disk,
as binary files. This opens a file, and determins the length of
the file, stores this info in LF - Length of File - and then
closes the file.
I will go into this in more detail in the next tutorial, for now
it is enought that it works.
Lines:
510 reserve as work BNK,LF
520 hide on : bload F$,BNK
Reserves a work area to the length of the squashed file, and loads
the Packed file into this workspace. It also hides the mouse.
The reason for the mouse being hidden, is so that when it is
displayed, you know that you have do do something. When it is
hidden you know the computer is working on something.
Lines:
530 rem
540 rem unsquashing file in a screen bank
550 rem
Ser the start od the actual UNSQUASHING.
Line:
560 copy start(8),start(8)+LF to start(7)
Copies the file from bank 8 to bank 7. It only copies the actual
amount of data that is required. You can store more than one
picture to a bank in PACked form, but I will explaine that in the
next tutorial.
Line:
570 unsquash 7,LF
UNSQUASHES the copied file. it is now a picture again, and can be
displayed to screen.
Lines:
580 locate 10,10
590 print F$;" IS LOADED" : wait 50
600 cls : return
Display a message and then tidy up before returning to where it
jumped from.
Lines:
610 show on
620 reset zone
630 for F=1 to 9
640 read A,B,C,D
650 set zone F,A,B to C,D
660 box A,B to C,D
670 next F
Were discussed in the first lesson. The only new point here is
the fact that the mouse is redisplayed to screen.
Lines:
680 rem
710 rem
720 rem
730 rem
760 rem
Should really have been deleted. I was going to add some code, so
I made some rems, but then I changed my mind, and forgot to delete
and renum.
Lines:
770 MK=0
780 repeat
790 K$=inkey$
800 if K$<>"" then default : end
810 MK=mouse key
820 until MK<>0
Have also been dealt with in lesson 1
Lines:
830 rem
860 goto 770
870 data 0,0,32,18,32,0,63,18
880 data 0,19,32,37,32,19,63,37
890 data 0,38,32,66,32,38,63,66
900 data 0,67,32,95,32,67,63,95
910 data 0,96,63,119
920 data 0,67,32,95,32,67,63,95
Were also dealt with in lesson 1.
Gosh, this is already 11 pages long, and I still have to deal with
the last programme yet.
lesson 4
This is a slight modification of JIGSAW 1. It loads sprites which
will store the picture, then loads the picture and the packed
screen. Displays things and then quits.
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 2 ***
40 rem *** ***
50 rem **************************
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 DRV=drive : drive=0 : dir$="A:\"
90 rem
100 HT=39 : WD=48
110 X1=63 : X2=196 : Y1=2 : Y2=319
120 JIG=25 : JHT=39 : JWD=48
130 rem
140 rem ------ grab sprites & make jigsaw
150 rem
160 if length(1)<>0 then goto 240
170 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
180 cls : show on : SPR$=file select$("*.MBK")
190 F$=SPR$ : BNK=1 : gosub 530
200 rem
210 rem
220 rem ---- Load a picture
230 rem
240 if length(6)<>0 then goto 320
250 if length(6)=0 then reserve as screen 6
260 locate 10,10 : print "LOAD PICTURE" : wait 50
270 cls : show on : SCR$=file select$("*.*")
280 F$=SCR$ : BNK=6 : gosub 530
290 rem
300 rem ---- Load a packed screen
310 rem
320 if length(7)<>0 then goto 390
330 if length(7)=0 then reserve as screen 7
340 locate 10,10 : print "LOAD PACed FILE" : wait 50
350 show on : PSCR$=file select$("*.pac")
360 F$=PSCR$ : BNK=8 : gosub 650
370 rem
380 rem
390 get palette (6)
400 screen copy 6 to back : screen copy 6 to physic
410 reduce 6 to 7,64,0,304,199
420 reduce 6 to 7,0,120,64,199
430 fade 5
440 fade 5,6
450 get palette (6)
460 screen copy 7 to back : screen copy 7 to physic
470 rem
480 wait 100 : goto 760
490 rem
500 rem
510 rem ------ FILE LOADER
520 rem
530 hide on : load F$,BNK
540 locate 10,10
550 print F$;" IS LOADED" : wait 50
560 cls : return
570 rem
580 rem ----- PACed FILE LOADER
590 rem
600 locate 10,10 : print "LOAD PACed FILE" : wait 50
610 if length(7)=0 then reserve as screen 7
620 rem
630 rem get size of file to unsquash
640 rem
650 open in #1,F$ : LF=lof(#1) : close #1
660 reserve as work BNK,LF
670 hide on : bload F$,BNK
680 rem
690 rem unsquashing file in a screen bank
700 rem
710 copy start(8),start(8)+LF to start(7)
720 unsquash 7,LF
730 locate 10,10
740 print F$;" IS LOADED" : wait 50
750 cls : return
760 show on
770 reset zone
780 for F=1 to 9
790 read A,B,C,D
800 set zone F,A,B to C,D
810 box A,B to C,D
820 next F
830 rem
840 MK=0
850 repeat
860 K$=inkey$
870 rem
880 MK=mouse key
890 until MK<>0
900 rem
910 if zone(0)=6 then goto 980
920 if zone(0)=9 then shoot : wait 100 : default : end
930 goto 840
940 rem
950 rem *** draw jigsaw grid ***
960 rem
970 rem
980 JHT=39 : JWD=48
990 rem
1000 X1=63 : X2=196 : Y1=2 : Y2=319
1010 X3=X1+JWD : Y3=Y1+JHT
1020 for F=1 to JIG
1030 box X1,Y1 to X3,Y3
1040 X3=X3+JWD
1050 if X3>=Y2 then X3=X1+JWD : Y1=Y1+JHT : Y3=Y1+JHT
1060 next F
1070 change mouse 4
1080 rem
1090 rem
1100 rem
1110 X=64 : Y=0
1120 for F=1 to JIG
1130 get sprite X,Y,F
1140 X=X+JIG
1150 if X>304-JWD then X=64 : Y=Y+JHT
1160 next F
1170 cls : wait 100
1180 X=64 : Y=0
1190 for F=1 to JIG
1200 sprite 1,X,Y,F
1210 wait vbl : put sprite 1
1220 X=X+JIG
1230 if X>=304 then X=64 : Y=Y+JHT
1240 next F
1250 cls
1260 dim LST(JIG),CH(JIG+1)
1270 for F=0 to JIG
1280 CH(F)=F
1290 next F
1300 cls
1310 repeat
1320 NUM=rnd(JIG)+1
1330 if LST(N)=0 and CH(NUM)<>0 then LST(N)=CH(NUM) else goto 1310
1340 inc N : CH(NUM)=0
1350 until N=JIG
1360 X=64 : Y=0
1370 for F=1 to JIG
1380 sprite 1,X,Y,LST(F-1)
1390 wait vbl : put sprite 1
1400 X=X+JWD
1410 if X>=304 then X=64 : Y=Y+JHT
1420 next F
1430 rem
1440 rem
1450 rem
1460 wait 200 : print "ABOUT TO QUIT PLEASE WAIT" : default : end
1470 rem
1480 rem
1490 data 0,0,32,18,32,0,63,18
1500 data 0,19,32,37,32,19,63,37
1510 data 0,38,32,66,32,38,63,66
1520 data 0,67,32,95,32,67,63,95
1530 data 0,96,63,119
1540 data 0,67,32,95,32,67,63,95
Although longer than the previous lesson, it is not really that
much different from it.
Lines:
10 rem **************************
20 rem *** ***
30 rem *** JIGSAW 2 ***
40 rem *** ***
50 rem **************************
Are the title.
Lines:
60 if mode<>0 then mode 0
70 cls : key off : curs off : hide on
80 DRV=drive : drive=0 : dir$="A:\"
Are the same as the previous lesson.
Lines:
90 rem
100 HT=39 : WD=48
110 X1=63 : X2=196 : Y1=2 : Y2=319
120 JIG=25 : JHT=39 : JWD=48
Store the variables needed to set up the screen. Ht= height; WD =
width of the sprites. X1, Y1 etc.. are the locations whet tha
picture will be drawn to screen in reduced form. JIG is the
number of sprites in the bank, and thus the number of pieces of
the jigsaw, and JHT and JWD are variables that also store the
width and height of the sprites in case I want to change them, but
also keep a default value as well.
Lines:
130 rem
140 rem ------ grab sprites & make jigsaw
150 rem
160 if length(1)<>0 then goto 240
170 locate 10,10 : print "LOAD A SPRITE BANK" : wait 50
180 cls : show on : SPR$=file select$("*.MBK")
190 F$=SPR$ : BNK=1 : gosub 530
Were dealt with in lesson 3 and loads a sprite bank.
Lines:
200 rem
210 rem
220 rem ---- Load a picture
230 rem
240 if length(6)<>0 then goto 320
250 if length(6)=0 then reserve as screen 6
260 locate 10,10 : print "LOAD PICTURE" : wait 50
270 cls : show on : SCR$=file select$("*.*")
280 F$=SCR$ : BNK=6 : gosub 530
Were dealt with in lesson 3 and loads a screen bank.
Lines:
290 rem
300 rem ---- Load a packed screen
310 rem
320 if length(7)<>0 then goto 390
330 if length(7)=0 then reserve as screen 7
340 locate 10,10 : print "LOAD PACed FILE" : wait 50
350 show on : PSCR$=file select$("*.pac")
360 F$=PSCR$ : BNK=8 : gosub 650
Were dealt with in lesson 3 and load a PACked file.
Lines:
370 rem
380 rem
390 get palette (6)
400 screen copy 6 to back : screen copy 6 to physic
410 reduce 6 to 7,64,0,304,199
420 reduce 6 to 7,0,120,64,199
430 fade 5
440 fade 5,6
450 get palette (6)
460 screen copy 7 to back : screen copy 7 to physic
Were also dealt with in lesson 3. They take the screen from bank
6 and reduce it and copy it to bank 7. The only point worth
noteing is that I am building up a screen from segments of Bank 6
and adding them together to form one picture.
Lines:
470 rem
480 wait 100 : goto 760
Wait a short time and then jumps to line 760. This is to give you
time to look at the picture.
Lines:
490 rem
500 rem
510 rem ------ FILE LOADER
520 rem
530 hide on : load F$,BNK
540 locate 10,10
550 print F$;" IS LOADED" : wait 50
560 cls : return
Were dealt with in lesson 3 and are the file loaders.
570 rem
580 rem ----- PACed FILE LOADER
590 rem
600 locate 10,10 : print "LOAD PACed FILE" : wait 50
610 if length(7)=0 then reserve as screen 7
620 rem
630 rem get size of file to unsquash
640 rem
650 open in #1,F$ : LF=lof(#1) : close #1
660 reserve as work BNK,LF
670 hide on : bload F$,BNK
680 rem
690 rem unsquashing file in a screen bank
700 rem
710 copy start(8),start(8)+LF to start(7)
720 unsquash 7,LF
730 locate 10,10
740 print F$;" IS LOADED" : wait 50
750 cls : return
Were dealt with in lesson 3 and are the file loaders.
Lines:
760 show on
770 reset zone 780 for F=1 to 9
790 read A,B,C,D
800 set zone F,A,B to C,D
810 box A,B to C,D
820 next F
Were dealt with in lesson 1 and set up the zones. THes zones are
there so that you can control the game once it is up an running.
At this moment in time they de very little, but in lesson 5 you
will see what they do.
Lines:
830 rem
840 MK=0
850 repeat
860 K$=inkey$
870 rem
880 MK=mouse key
890 until MK<>0
Were explained in lesson 1 and set up a loop to test for a key or
mouse key being pressed. In this case 'K$' does not do any thing,
and could have been removed.
Lines:
900 rem
910 if zone(0)=6 then goto 980
920 if zone(0)=9 then shoot : wait 100 : default : end
930 goto 840
Test for the zones. It tests for ZONE(0) becaus the mouse is
sprite zero, and that is what we are testing for. It could take
the form ZONE(0) to ZONE(15) as there are 16 sprites to choose
from at any one time.
Lines:
940 rem
950 rem *** draw jigsaw grid ***
960 rem
970 rem
Are the start of the actual jigsaw drawing bit.
Line:
980 JHT=39 : JWD=48
Sets the size of a jigsaw piece.
Lines:
990 rem
1000 X1=63 : X2=196 : Y1=2 : Y2=319
1010 X3=X1+JWD : Y3=Y1+JHT
Set the location to draw to.
Lines:
1020 for F=1 to JIG
1030 box X1,Y1 to X3,Y3
1040 X3=X3+JWD
1050 if X3>=Y2 then X3=X1+JWD : Y1=Y1+JHT : Y3=Y1+JHT
1060 next F
Set up a loop to draw boxes to screen. These boxes are tha same
sise as the sprites that will form the jigsaw pieces.
Line:
1070 change mouse 4
Changes the mouse into the first sprite in the sprite bank. Thus
it changes it into a piece of the jigsaw if one is available.
Lines:
1080 rem
1090 rem
1100 rem
1110 X=64 : Y=0
1120 for F=1 to JIG
1130 get sprite X,Y,F
1140 X=X+JIG
1150 if X>304-JWD then X=64 : Y=Y+JHT
1160 next F
Copy the screen to the sprite bank. The routine checks to see how
far across the screen it is against how wide the sprites are.
Line:
1170 cls : wait 100
Waits a short time after clearing the screen.
Lines:
1180 X=64 : Y=0
1190 for F=1 to JIG
1200 sprite 1,X,Y,F
1210 wait vbl : put sprite 1
1220 X=X+JIG
1230 if X>=304 then X=64 : Y=Y+JHT
1240 next F
Are much the same as the previous lines, except this time they are
placing the sprites to screen to form a picture.
Line:
1250 cls
Clears the screen ready for the scrambling of the jigsaw.
Lines:
1260 dim LST(JIG),CH(JIG+1)
1270 for F=0 to JIG
1280 CH(F)=F
1290 next F
1300 cls
Are where the new sprite order is stored. I will discuss this in
detail in the next tutorial. I have already touched on it in a
previous tutorial, but will go over it again anyway.
Lines:
1310 repeat
1320 NUM=rnd(JIG)+1
1330 if LST(N)=0 and CH(NUM)<>0 then LST(N)=CH(NUM) else goto 1310
1340 inc N : CH(NUM)=0
1350 until N=JIG
1360 X=64 : Y=0
1370 for F=1 to JIG
1380 sprite 1,X,Y,LST(F-1)
1390 wait vbl : put sprite 1
1400 X=X+JWD
1410 if X>=304 then X=64 : Y=Y+JHT
1420 next F
Displays the jumbled pieced back to screen. Again I will explain
this in more deatail next time. But it was also dealt with in the
same tutorial as the previous lines.
Lines:
1430 rem
1440 rem
1450 rem
1460 wait 200 : print "ABOUT TO QUIT PLEASE WAIT" : default : end
Just tell you that the programme is about to end. then it does
just that.
Lines:
1470 rem
1480 rem
1490 data 0,0,32,18,32,0,63,18
1500 data 0,19,32,37,32,19,63,37
1510 data 0,38,32,66,32,38,63,66
1520 data 0,67,32,95,32,67,63,95
1530 data 0,96,63,119
1540 data 0,67,32,95,32,67,63,95
Are the same as the previous data statements in principle, so I
will not dwell on them here.
Due to problems with my computer repeadedly crashing - I have a
faulty programme somewhere but cannot locate which one it is - I
am not going to be able to deal with this final lesson in much
detail. I will sort out the problem and include This lesson in
next months ot the month after that.
It also means that I have not been able to check for typeing
errors, so if there are any mistakes, then just look at the keys
around the problem word. i.e. THEN could be RHEN etc..
PLEASE CLICK ON BASIC TUT 10/2 For next part of this Tutorial